import pygame


def main():
    pygame.init()
    screen = pygame.display.set_mode((800, 600), 0, 32)

    all_colors = pygame.Surface((4096, 4096), depth=24)

    for r in range(256):
        print("%s out of 256" % r)
        x = (r & 15) * 256
        y = (r >> 4) * 256
        for g in range(256):
            for b in range(256):
                all_colors.set_at((x + g, y + b), (r, g, b))

    pygame.image.save(all_colors,"all_color.bmp")

    screen.blit(all_colors, (0, 0))

    pygame.display.update()

    while True:
        event = pygame.event.wait()
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                exit()
        if event.type == pygame.QUIT:
                exit()


main()
